extends MarginContainer
class_name ScheduleElement

@export var time_text: String = ""
@export var thing_text: String = ""
@export var place_text: String = ""

func update_elements(st1: String, st2: String, st3:String):
	%TimeEdit.text = st1
	%ThingEdit.text = st2
	%PlaceEdit.text = st3
	time_text = st1
	thing_text = st2
	place_text = st3
	
func _ready() -> void:
	# 透明度动画
	modulate.a = 0
	modulate_animation(self, 1)

#region 动画

# 淡入动画
func modulate_animation(obj: Object, final_modulate: int):
	var tween := create_tween()
	tween.set_trans(Tween.TRANS_QUINT)
	tween.tween_property(obj, "modulate:a", final_modulate, .3)
	
# 删除动画
func play_queue_animation():
	var tween := get_tree().create_tween()
	tween.set_trans(Tween.TRANS_QUINT)
	tween.tween_property(self, "modulate:a", 0, .3)
	await tween.finished
	queue_free()
#endregion
#region 文本编辑逻辑

func _on_time_edit_text_submitted(new_text: String) -> void:
	if (new_text == ""):
		play_queue_animation()
#endregion


func _on_button_pressed() -> void:
	play_queue_animation()
